#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void bubble(int arr[], int sz)
{
	int i = 0;
	int flag = 1;
	for (i = 0; i < sz - 1; i++)
	{
		int j = 0;
		for (j = 0; j < sz - 1 - i; j++)
		{
			if (arr[j] > arr[j + 1])
			{
				int tamp = arr[j];
			    arr[j] = arr[j+1];
			    arr[j+1] = tamp;
			    flag = 0;

			}
			
		}
		if (flag == 1)
		{
			break;
		}
	}
	
}

int main()
{
	int i = 0;
	int arr[9] = { 8,9,7,6,5,4,3,2,1 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	bubble(arr, sz);
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}